Skip to content

Unify VFS interfaces#967

Draft
rodinaarssen wants to merge 169 commits intomainfrom
unify-vfs-interfaces
Draft

Unify VFS interfaces#967
rodinaarssen wants to merge 169 commits intomainfrom
unify-vfs-interfaces

Conversation

@rodinaarssen
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@toinehartman toinehartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive amount of work again! Although I trust your local testing, I think it would be nice to see an all-green CI by using a test-only snapshot release of Rascal if possible.

Comment thread rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java Outdated
Comment thread rascal-vscode-extension/src/fs/RascalFileSystemInVSCode.ts Outdated
.filter(s => !this.protectedSchemes.includes(s))
// we add support for schemes that look inside a jar
.concat(schemes
.filter(s => s !== "jar" && s !== "zip" && s !== "compressed")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compressed:? Never seen that before. How can that be used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for dynamically decompressing a file. It's used for large data sets for example: readFile(|compressed+file:///big-data-set.csv.gz|) or readCSV(|compressed+home:///big-data-set.csv.gz|);

readDirectory(uri: vscode.Uri): [string, vscode.FileType][] | Thenable<[string, vscode.FileType][]> {
this.logger.trace("[RascalFileSystemInVSCode] readDirectory: ", uri);
return this.sendRequest<DirectoryListingResponse>(uri, "rascal/vfs/input/list")
.then(c => c.entries.map(ft => [ft.name, ft.types.reduce((a, i) => a | i)]));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the reduce?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types is an (admittedly mostly singleton) array of file types (e.g., file and symbolic link), which are encoded as a single bit. The reduce converts the array into a bitmap.

Comment thread rascal-vscode-extension/src/fs/VSCodeFileSystemInRascal.ts Outdated
Comment thread rascal-vscode-extension/src/fs/VSCodeFileSystemInRascal.ts
@Override
public CompletableFuture<SourceLocationResponse> resolveLocation(ISourceLocationRequest req) {
logger.trace("resolveLocation: {}", req.getLocation());
return super.resolveLocation(new ISourceLocationRequest(Locations.toClientLocation(req.getLocation())));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we introduce a small utilty function that can reconstruct a ISourceLocationRequest as right now the Locations.toClientLocation is repeated in quite some places.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this

* Wrapper for RascalFileSystemServices handling LSP-specifics.
* In particular, locations from LSP are mapped to Rascal-friendly locations, and Rascal exceptions are mapped to exceptions LSP expects.
*/
public class RascalFileSystemInVSCode extends RascalFileSystemServices {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment that explains why not all calls over overriden? it looks to me like there should be more?

.setOutput(out)
.configureGson(GsonUtils.complexAsJsonObject())
.setExecutorService(threadPool)
.setExceptionHandler(t -> RemoteIOError.translate((Exception) t).getResponseError())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should only call this if it's an IOException as it might already be a RespondseException or something else.

I think we already have something like this to deal with exceptions that should be send to the VS Code UI for error reporting.

Comment thread rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java Outdated

async watch(newWatch: WatchRequest): Promise<void> {
this.logger.trace("[VSCodeFileSystemInRascal] watch: ", newWatch.loc);
const watchKey = newWatch.loc + newWatch.recursive;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should a charcter between the loc and the boolean, such that we never get colissions. for example:

const watchKey = `${newWatch.loc}##${newWatch.recursive}`;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could there a collision here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm, I was thinking about a file named true or something, but that's not right, it'll still het the boolean suffix.

this.disposables.push(watcher);
return;
}
throw new rpc.ResponseError(RemoteIOError.watchAlreadyDefined, `Watch already defined: ${newWatch.loc}`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only works because we provide some guarantees of never being called twice. I think we should document some of that on the java classes.

Comment thread rascal-vscode-extension/src/fs/VSCodeFileSystemInRascal.ts Outdated
Comment thread rascal-vscode-extension/src/RascalExtension.ts
Comment thread rascal-vscode-extension/src/RascalTerminalLinkProvider.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants